package vista;


import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import modelo.Jugador;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaListadoModeloTabla extends AbstractTableModel {

	private static String[] titulos = {"Nombre","Tiempo","Nivel"};
	private List<Jugador> jugadores = new ArrayList<Jugador>();
	
	
	public VentanaListadoModeloTabla(List<Jugador> jugadores) {
		super();
		this.jugadores = jugadores;
		this.fireTableDataChanged();
	}

	@Override
	public int getColumnCount() {		
		return titulos.length;
	}

	@Override
	public int getRowCount() {		
		return jugadores.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Jugador jugador = jugadores.get(rowIndex);
		switch (columnIndex) {
			case 0: return jugador.getnombre();
			case 1: return jugador.gettiempo();
			case 2: return jugador.getNivel();
			}
		return null;
	}

	@Override
	public String getColumnName(int column) {
		return titulos[column];
	}
	
}
